package com.ruoyi.service.impl;

import com.ruoyi.entity.po.TChatRoomPopularity;
import com.ruoyi.entity.vo.ChatRoomPopularityVo;
import com.ruoyi.mapper.TChatRoomPopularityMapper;
import org.springframework.stereotype.Service;

import org.springframework.beans.factory.annotation.Autowired;

import com.ruoyi.entity.po.TPlayerChatRoom;
import com.ruoyi.mapper.TPlayerChatRoomMapper;
import com.ruoyi.service.IPlayerChatRoomService;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author chenhainan
 * @since 2024-12-09 20:36
 */
@Service
public class PlayerChatRoomServiceImpl implements IPlayerChatRoomService {

    @Autowired
    private TPlayerChatRoomMapper tPlayerChatRoomMapper;

    @Autowired
    private TChatRoomPopularityMapper tChatRoomPopularityMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return tPlayerChatRoomMapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional
    public int deleteByPrimaryKeys(Integer[] ids) {
        tPlayerChatRoomMapper.deleteByPrimaryKeys(ids);
        return tChatRoomPopularityMapper.deleteByRoomIds(ids);
    }

    @Override
    public int insert(TPlayerChatRoom record) {
        return tPlayerChatRoomMapper.insert(record);
    }

    @Override
    @Transactional
    public int insertSelective(TPlayerChatRoom record) {
        tPlayerChatRoomMapper.insertSelective(record);
        return tChatRoomPopularityMapper.insert(new TChatRoomPopularity(record.getId()));
    }

    @Override
    public TPlayerChatRoom selectByPrimaryKey(Integer id) {
        return tPlayerChatRoomMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<TPlayerChatRoom> selectChatRommList(TPlayerChatRoom playerChatRoom) {
        return tPlayerChatRoomMapper.selectChatRommList(playerChatRoom);
    }

    @Override
    public int updateByPrimaryKeySelective(TPlayerChatRoom record) {
        return tPlayerChatRoomMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TPlayerChatRoom record) {
        return tPlayerChatRoomMapper.updateByPrimaryKey(record);
    }

    @Override
    public TPlayerChatRoom selectByPlayerName(String playerName) {
        return tPlayerChatRoomMapper.selectByPlayerName(playerName);
    }

    @Override
    public void updateRoomNameByPlayerName(String playerName, String roomName) {
        tPlayerChatRoomMapper.updateRoomNameByPlayerName(playerName, roomName);
    }

    @Override
    public TPlayerChatRoom selectByPlayerId(Integer playerId) {
        return tPlayerChatRoomMapper.selectByPlayerId(playerId);
    }

    @Override
    public List<ChatRoomPopularityVo> chatRoomPopularity(Integer playerId) {
        return tChatRoomPopularityMapper.chatRoomPopularity(playerId);
    }
}
